<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0, width=device-width"/>
        <meta name="format-detection" content="telephone=no"/>
        <title>信号量列表</title>
        <link rel="stylesheet" type="text/css" href="../../css/api.css" />
        <link rel="stylesheet" type="text/css" href="../../css/common.css" />
        <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
        <link rel="stylesheet" href="../../script/ccssoft/css/ccssoft-lite.css" />
        <style>
            body {
                background-color: #eff1f0;
            }
            ul, li {
                margin: 0;
                padding: 0;
            }
            .ccssoft_list li {
                list-style: none;
                padding: 8px;
                border-bottom: 1px solid #e3e2e2;
                background: #fff;
                overflow: hidden;
                margin-bottom: 10px;
            }
            .ccssoft_list li:hover {
                background: #f9e9df;
            }
            .ccssoft_list li:active {
                background: #f9e9df;
            }
            .liTopLeft {
                float: left;
                width: 15%;
                height: 40px;
                line-height: 40px;
            }
            .liTopRight {
                float: left;
                width: 85%;
                height: 40px;
            }
            .liRightName {
                width: 100%;
                height: 20px;
                line-height: 20px;
                text-align: left;
                font-size: 16px;
                font-weight: bold;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                padding-left: 5px;
            }
            .liRightType {
                width: 100%;
                height: 20px;
                line-height: 20px;
                text-align: left;
                font-size: 12px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                padding-left: 5px;
                color: #ADADAD;
            }
            .liRightDownCode {
                float: left;
                width: 50%;
                height: 18px;
                line-height: 18px;
                text-align: left;
                color: #ADADAD;
                font-size: 12px;
                padding-left: 10px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            .liRightDownCount {
                float: left;
                width: 50%;
                height: 18px;
                line-height: 18px;
                text-align: left;
                color: #ADADAD;
                font-size: 12px;
                padding-left: 15px;
            }
            .liTop {
                width: 100%;
                height: 43px;
                padding-bottom: 3px;
                border-bottom: 1px solid #e3e2e2;
            }
            .liDown {
                width: 100%;
                height: 21px;
                padding-top: 3px;
                font-size: 12px;
            }
        </style>
    </head>
    <body>
        <div id="main">
            <script id="signalList-template" type="text/x-dot-template">
                {{ for(var i=0, len=it.length; i < len; i++) { }}
                <li tapmode="active"  onclick="openSignalDetail(this)" semaphoreId="{{=it[i].id}}" semaphorename="{{=it[i].semaphorename}}" measureval="{{=it[i].measureval}}">
                <div class="liTop">
                <div class="liTopLeft">
                <img src="../../image/home_gv_contactor.png" width="40px" height="40px"/>
                </div>
                <div class="liTopRight">
                <div class="liRightName">{{=it[i].semaphorename}}</div>
                <div class="liRightType">信号指标类型：{{=it[i].semaphoretype}}</div>
                </div>
                </div>
                <div class="liDown">
                <div class="liRightDownCode">信号指标状态：{{=it[i].semaphorestatus}}</div>
                <!--<div class="liRightDownCount">信号指标值：{{=it[i].measuredval}}</div>-->
                <div class="liRightDownCount">信号指标值：{{=it[i].measureval}}</div>
                </div>
                </li>
                {{ } }}
            </script>
            <ul class="ccssoft_list" id="signalList"></ul>
        </div>
    </body>
    <script src="../../script/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/constant.js"></script>
    <script type="text/javascript" src="../../script/debug.js"></script>
    <script type="text/javascript" src="../../script/doT.min.js"></script>
    <script type="text/javascript" src="../../script/common.js"></script>
    <script type="text/javascript" src="../../script/config.js"></script>
    <script type="text/javascript" src="../../script/client.api.js"></script>
    <script type="text/javascript" src="../../script/aui-alert.js"></script>
    <script>
        var start = 0;
        var loadDone = false;
        var showProgress = true;
        function openSignalDetail(el) {
            var semaphorename = $api.attr(el, 'semaphorename');
            var measureval = $api.attr(el, 'measureval');
            var semaphoreId = $api.attr(el, 'semaphoreId');
            var pageParam = {};
            pageParam.measureval = measureval;
            pageParam.semaphorename = semaphorename;
            pageParam.semaphoreId = semaphoreId;
            pageParam.showFlag = api.pageParam.showFlag;
            pageParam.stationId = api.pageParam.stationId;
            pageParam.deviceCode = api.pageParam.deviceCode;
            pageParam.devFsuId = api.pageParam.devFsuId;
            pageParam.deviceName = api.pageParam.deviceName;
            //  pageParam = $.extend(pageParam, api.pageParam);
            //  showlog("signalList_frm156 " + getObj(pageParam));
            api.openWin({
                name : 'signalRealData',
                url : 'devSignalReal.html',
                opaque : true,
                bounces : false,
                reload : true,
                pageParam : pageParam,
                vScrollBarEnabled : false
            });
        }

        function getSignalList() {
            if (api.pageParam.deviceCode != null) {
                //		var user = $api.getStorage('user');
                //		var userid = user.userid;
                var devFsuId = api.pageParam.devFsuId;
                var showflag = api.pageParam.showFlag;
                var deviceCode = api.pageParam.deviceCode;
                var areaid = api.pageParam.stationId;
                var opts = {
                    showflag : showflag,
                    fsuId : devFsuId,
                    deviceCode : deviceCode,
                    areaid : areaid,
                    signalType : api.pageParam.signalType,
                    start : start
                };

                showlog("devFsuId "+devFsuId+" deviceCode "+deviceCode);
                api.showProgress({
                    title : '加载中',
                    modal : false
                });
                $client.getSimpleOrAllSignalListByType(opts, function(ret, err) {
                    if (ret) {
                        if (ret.success) {
                            //var strs = $api.jsonToStr(ret);
                            //alert(strs);
                            // alert(JSON.stringify(ret.list))
                            if (ret.list == null || ret.list.length < 1) {
                                loadDone = true;
                                $('body').addClass('active');
                            } else {
                                $('body').removeClass('active');
                                var content = $api.byId('signalList');
                                var tpl = $api.byId('signalList-template').text;
                                var tempFn = doT.template(tpl);
                                if (start == 0) {
                                    content.innerHTML = tempFn(ret.list);
                                } else {
                                    content.innerHTML += tempFn(ret.list);
                                }
                            }
                        } else {
                            $('body').addClass('active');
                            api.toast({
                                msg : ret.data_info,
                                location : 'middle'
                            });
                        }
                    } else {
                        $('body').addClass('active');
                        api.toast({
                            msg : err.msg,
                            location : 'middle'
                        });
                    }
                    if (start == 0) {
                        api.refreshHeaderLoadDone();
                        api.parseTapmode();
                    }
                    window.setTimeout(function() {
                        api.parseTapmode();
                        api.hideProgress();
                    }, 500);
                });
            } else {
                loadDone = true;
            }
        }

        apiready = function() {
            getSignalList();
//          $(window).scroll(function() {
//              if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
//                  if (!loadDone) {
//                      start += 1;
//                      showProgress = true;
//                      getSignalList();
//                  }
//              }
//          });
//          api.setRefreshHeaderInfo({
//              visible : true,
//              bgColor : '#f2f2f2',
//              textColor : '#4d4d4d',
//              textDown : '下拉刷新...',
//              textUp : '松开刷新...',
//              showTime : true
//          }, function(ret, err) {
//              start = 0;
//              loadDone = false;
//              showProgress = false;
//              getSignalList();
//          });
        }
        //隐藏FrameGroup
        function hiddenFrameGroup() {
            api.setFrameGroupAttr({
                name : 'signal_header_tab',
                hidden : true
            });
        }

        //显示FrameGroup
        function showFrameGroup() {
            api.setFrameGroupAttr({
                name : 'signal_header_tab',
                hidden : false
            });
        }
    </script>
</html>
